home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WFILEDLG.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  7.5 KB  |  230 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WFileDialog -- FileDialog class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       FolderChange --
  19.  *
  20.  *       NewFileType --
  21.  *
  22.  *       SharingViolation --
  23.  *
  24.  *************************************************************************/
  25.  
  26. #ifndef _WFILEDIALOG_HPP_INCLUDED
  27. #define _WFILEDIALOG_HPP_INCLUDED
  28.  
  29. #ifndef _WNO_PRAGMA_PUSH
  30. #pragma pack(push,8);
  31. #pragma enum int;
  32. #endif
  33.  
  34. #ifndef _WCOMDLG_HPP_INCLUDED
  35. #  include "wcomdlg.hpp"
  36. #endif
  37.  
  38. // WFileFilter
  39. //
  40. //    Used for building filter lists.
  41.  
  42. struct WFileFilter {
  43.     const WChar *title;
  44.     const WChar *pattern;
  45. };
  46.  
  47. // Styles
  48.  
  49. typedef WULong WFDStyle;
  50.  
  51. #define WFDSReadOnly                 ((WFDStyle)0x00000001L)
  52. #define WFDSOverWritePrompt          ((WFDStyle)0x00000002L)
  53. #define WFDSHideReadOnly             ((WFDStyle)0x00000004L)
  54. #define WFDSNoChangeDir              ((WFDStyle)0x00000008L)
  55. #define WFDSShowHelp                 ((WFDStyle)0x00000010L)
  56. #define WFDSEnableHook               ((WFDStyle)0x00000020L)
  57. #define WFDSEnableTemplate           ((WFDStyle)0x00000040L)
  58. #define WFDSEnableTemplateHandle     ((WFDStyle)0x00000080L)
  59. #define WFDSNoValidate               ((WFDStyle)0x00000100L)
  60. #define WFDSAllowMultiSelect         ((WFDStyle)0x00000200L)
  61. #define WFDSExtensionDifferent       ((WFDStyle)0x00000400L)
  62. #define WFDSPathMustExist            ((WFDStyle)0x00000800L)
  63. #define WFDSFileMustExist            ((WFDStyle)0x00001000L)
  64. #define WFDSCreatePrompt             ((WFDStyle)0x00002000L)
  65. #define WFDSShareAware               ((WFDStyle)0x00004000L)
  66. #define WFDSNoReadOnlyReturn         ((WFDStyle)0x00008000L)
  67. #define WFDSNoTestFileCreate         ((WFDStyle)0x00010000L)
  68. #define WFDSNoNetworkButton          ((WFDStyle)0x00020000L)
  69. #define WFDSNoLongNames              ((WFDStyle)0x00040000L)
  70. #define WFDSExplorer                 ((WFDStyle)0x00080000L)
  71. #define WFDSNoDereferenceLinks       ((WFDStyle)0x00100000L)
  72.  
  73. // WFileDialog
  74. //
  75. //    Used to display open/save dialog.
  76.  
  77. class WCMCLASS WFileDialog : public WCommonDialog {
  78.     WDeclareSubclass( WFileDialog, WCommonDialog );
  79.  
  80.     public:
  81.         WFileDialog();
  82.  
  83.         ~WFileDialog();
  84.  
  85.         /*******************************************************
  86.          * Properties
  87.          *******************************************************/
  88.  
  89.         // BufferSize
  90.         //
  91.         //    Sets the buffer size to be used.
  92.  
  93.         WULong GetBufferSize() const;
  94.         WBool  SetBufferSize( WULong bufferSize );
  95.  
  96.         // ButtonLabel
  97.         //
  98.         //    Sets an alternative label for the Open/Save button.
  99.         //    An empty string means to use the system default.
  100.  
  101.         WString GetButtonLabel() const;
  102.         WBool   SetButtonLabel( const WChar *label );
  103.  
  104.         // FileCount
  105.         //
  106.         //    Number of files selected after dialog returns
  107.         //    or to initially display.  Always at least 1.
  108.  
  109.         WULong  GetFileCount() const;
  110.         WBool   SetFileCount( WULong count=1 );
  111.  
  112.         // FilePath
  113.         //
  114.         //    The path of the file that was selected.  Use this
  115.         //    to set the initial file path as well.  If multiple
  116.         //    files were selected, use the optional parm to GetFilePath
  117.         //    to return the files from 0..FileCount-1.
  118.  
  119.         WFilePath GetFilePath( WULong whichFile=0 ) const;
  120.         WBool     SetFilePath( const WFilePath & path, WULong whichFile=0 );
  121.  
  122.         // FilterIndex
  123.  
  124.         WULong GetFilterIndex() const;
  125.         WBool  SetFilterIndex( WULong filterIndex );
  126.  
  127.         // FilterList
  128.         //
  129.         //    Sets the list of filters that will be used.  Note
  130.         //    that the dialog does not make a private copy of
  131.         //    the list.  The list is just an array of WFileFilters,
  132.         //    the last one being NULL.
  133.  
  134.         const WFileFilter *GetFilterList() const;
  135.         WBool              SetFilterList( const WFileFilter *list );
  136.  
  137.         // InitialDirectory
  138.         //
  139.         //    Sets the initial directory used by the file dialog.
  140.         //    If empty string, uses the current directory.
  141.  
  142.         WString GetInitialDirectory() const;
  143.         WBool   SetInitialDirectory( const WString & initDir );
  144.  
  145.         // MultiSelect
  146.         //
  147.         //    Sets/gets the multiselect state.  Note that if you
  148.         //    call SetFilePath to set multiple file paths, or set
  149.         //    the file count to > 1, this mode is automatically turned on.
  150.  
  151.         WBool GetMultiSelect() const;
  152.         WBool SetMultiSelect( WBool on );
  153.  
  154.         // Style
  155.         //
  156.         //    Set the styles used by the file dialog.  Note that
  157.         //    the WFDSEnableHook style will ALWAYS be enabled.
  158.  
  159.         WFDStyle GetStyle() const;
  160.         WBool    SetStyle( WFDStyle style );
  161.  
  162.         /*******************************************************
  163.          * Methods
  164.          *******************************************************/
  165.  
  166.         // ChangeStyle
  167.         //
  168.         //    Use to turn a specific style on or off.
  169.  
  170.         WBool ChangeStyle( WFDStyle style, WBool on );
  171.  
  172.         // PromptForOpen
  173.         //
  174.         //    Display the "Open" dialog and wait for it to be dismissed.
  175.         //    The first form uses the current settings.  The second
  176.         //    is a convenience function.
  177.  
  178.         WBool PromptForOpen();
  179.  
  180.         WBool PromptForOpen( WWindow *owner, const WChar *initialPath,
  181.                              const WChar *title,
  182.                              const WFileFilter filterList[] );
  183.  
  184.         // PromptForSave
  185.         //
  186.         //    Display the "Save as" dialog and wait for it to be dismissed.
  187.  
  188.         WBool PromptForSave();
  189.  
  190.         WBool PromptForSave( WWindow *owner, const WChar *initialPath,
  191.                              const WChar *title, 
  192.                              const WFileFilter filterList[] );
  193.  
  194.         /********************************************************
  195.          * Static Properties
  196.          ********************************************************/
  197.  
  198.         // The default filter: "All Files (*.*)"
  199.         
  200.         static const WFileFilter * GetDefaultFilterList();
  201.  
  202.         /********************************************************
  203.          * Notifications
  204.          ********************************************************/
  205.  
  206.         void OnDialogInitialize( WWindowHandle hWnd, WWindowHandle focus );
  207.  
  208.     protected:
  209.  
  210.         virtual void  *PackOFN();
  211.         virtual WBool  UnpackOFN( WBool ok );
  212.  
  213.     protected:
  214.  
  215.         void              *_ofn;
  216.         const WFileFilter *_filterList;
  217.         WString            _buttonLabel;
  218.         WString            _initialDir;
  219.         WULong             _fileCount;
  220.         WFilePath        **_fileList;
  221.         WULong             _bufferSize;
  222. };
  223.  
  224. #ifndef _WNO_PRAGMA_PUSH
  225. #pragma enum pop;
  226. #pragma pack(pop);
  227. #endif
  228.  
  229. #endif // _WFILEDIALOG_HPP_INCLUDED
  230.